package com.lvmama.java.rhino.etl.process;

import java.io.Serializable;

import org.apache.log4j.Logger;

import com.lvmama.java.rhino.spark.core.ICallback;
import com.lvmama.java.rhino.spark.core.ISparkExecuting;
import com.lvmama.java.rhino.spark.core.ISparkShutdown;
import com.lvmama.java.rhino.spark.utils.Constants;
import com.lvmama.java.rhino.spark.utils.ZookeeperUtils;

public class SparkShutdownProcesser implements ISparkExecuting, ISparkShutdown, Serializable{

	private static final long serialVersionUID = -1114268721663797450L;
	private static final String SPARK_ZOOKEEPER_ROOT = Constants.SPARK_ZOOKEEPER_ROOT;
	private static final Logger LOGGER = Logger.getLogger(SparkShutdownProcesser.class);
	@Override
	public void run(String[] args, ICallback callback) {
		String appName = args[0];
		String path = SPARK_ZOOKEEPER_ROOT + "/" + appName;
		if (!ZookeeperUtils.getInstance().exist(path)) {
			ZookeeperUtils.getInstance().create(path, "sparkstreaming proceesor");
		}
		LOGGER.info("Processer: " + appName + "Shutdown!!");
	}

	@Override
	public void shutdown(String[] args) {
		
	}

}
